package com.zhang.learnnacos.app1.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.service.Contact;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zhanghaolian
 * @date 2021/6/5 17:53
 */
@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI()
                .info(new Info().title("SpringShop API")
                        .description("Spring shop sample application")
                        .version("v0.0.1")
                        .license(new License().name("Apache 2.0").url("http://springdoc.org")))
                .externalDocs(new ExternalDocumentation()
                        .description("SpringShop Wiki Documentation")
                        .url("https://springshop.wiki.github.org/docs"));
    }

//    @Bean
//    public Docket myDocket() {
//        Docket docket = new Docket(DocumentationType.SWAGGER_2).groupName("controller");
//
//        // 构建apiInfo
//        ApiInfo apiInfo = new ApiInfoBuilder()
//                .title("SWAGGER学习文档")
//                .description("仅用于个人学习")
//                .contact(new Contact("张先生的开发文档", "https://www.baidu.com", "453192907@qq.com"))
//                .version("1.0")
//                .build();
//        docket.apiInfo(apiInfo);
//
//        // 添加需要扫面的的包以及忽略规则
//        docket
//                .select()
//                .apis(
//                        RequestHandlerSelectors.basePackage("com.zhang.learnnacos.app1.controller")
//                )
//                .build();
//
//        return docket;
//    }
}
